class Solution {//leetcode121——买卖股票的最佳时机
public:
    int maxProfit(vector<int>& prices) {
        int n=prices.size();
        int min_price=INT_MAX,ret=0;
        for(int i=0;i<n;i++){
            ret=max(ret,prices[i]-min_price);
            min_price=min(min_price,prices[i]);
        }
        return ret;
    }
};